# # TODO：输入带宽和各个数据流需求，使用max-min算法分配，用来生成数据集，还没实现
# def mmf(bd,f1,f2,f3,f4):
#     output = [0,0,0,0]
#     num = 4
#     for i in range(num):
#         average = bd / num
#         min(f1,f2,f3,f4)
import numpy as np
import random
# TODO：输入带宽和各个数据流需求，使用max-min算法分配，用来生成数据集，还没实现
def mmf(bd,f1_4):
    num=4
    f1_4.sort()
    res = f1_4
    bd_avg_1=bd/num
    res=[bd_avg_1,bd_avg_1,bd_avg_1,bd_avg_1]
    num-=1
    if f1_4[0]<bd_avg_1:
        bd_avg_2=(bd_avg_1-f1_4[0])/num
        num -= 1
        res[0],res[1],res[2],res[3]=res[0],res[1]+bd_avg_2,res[2]+bd_avg_2,res[3]+bd_avg_2
        if f1_4[1]<res[1]:
            bd_avg_3 = (res[1] - f1_4[1]) / num
            num -= 1
            res[0], res[1], res[2], res[3] = res[0], res[1], res[2] + bd_avg_3, res[3] + bd_avg_3
            if f1_4[2]<res[2]:
                bd_avg_4 = (res[2] - f1_4[2]) / num
                num -= 1
                res[0], res[1], res[2], res[3] = res[0], res[1], res[2], res[3] + bd_avg_4
    else:
        return res
    return res

def data_generator(data_num):
    bds=[]
    f1_4s=[]
    labels=[]
    for i in range(1,data_num+1):
        bd = [random.randint(1,(30//4))*1.0]*4
        f1_4 = [random.random()*10.0, random.random()*10.0, random.random()*10.0, random.random()*10.0]
        bds.append(bd)
        f1_4s.append(f1_4)
        labels.append(mmf(bd[0],f1_4))
    return (bds,f1_4s,labels)

if __name__ == '__main__':
    bds,f1_4s,labels=data_generator(100)
    print(bds)
    print(f1_4s)
    print(labels)
